home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -serious- / programming / other / tandem / teaching / 43.asm < prev    next >
Assembly Source File  |  1999-09-06  |  3KB  |  97 lines

  1. * 43.asm   TLwpoll, TLwsub       0.01     8.6.99
  2.  
  3.  
  4.  include 'Front.i'         ;*** change to 'Tandem.i' to step thru TL's ***
  5.  
  6.  
  7. ; This program shows how to have several windows at once. In practice, each
  8. ; window would have its own subroutine to do whatever that window does.
  9. ; A window will keep calling TLKeyboard. If it returns resize, then re-draw
  10. ; the window. It it returns close, then close the window. If it returns
  11. ; inactive window, exit from the window, and call TLWpoll to wait for a
  12. ; window to become active. All other inputs would be dealt with within
  13. ; the context of whatever that window is for. Each window can have its own
  14. ; help, can call requesters, or be used for TLmultiline. Each can make use
  15. ; of the fonts in FSuite. There can be up to 10 windows, numbered 0-9.
  16.  
  17. ; You should study this program carefully - Amiga programming relies
  18. ; heavily on mastering the difficult art of managing a suit of windows.
  19.  
  20.  
  21. open: ds.w 1               ;number of open windows
  22. spen: dc.l -1              ;pens for screen
  23.  
  24.  
  25. strings: dc.b 0
  26.  dc.b 'Iteration '
  27. st_1a: dc.b 'A: Window '
  28. st_1b: dc.b '2 is active',0 ;1
  29.  dc.b 'Error: out of memory',0 ;2
  30.  dc.b 'Error: can''t open windows - out of mem',0 ;3
  31.  dc.b 'Error: can''t open window 2 - out of mem',0 ;4
  32.  dc.b 'move windows about, click them, size them, & close them',0 ;5
  33. st_6: dc.b 'A Private Screen',0 ;6
  34. st_7: dc.b 'Window 0',0 ;7
  35. st_8: dc.b 'Window 1',0 ;8
  36. st_9: dc.b 'Window 2',0 ;9
  37.  
  38.  ds.w 0
  39.  
  40.  
  41. Program:
  42.  move.b #'Z',st_1a         ;initialise string 1
  43.  TLscreen #2,#st_6,#spen   ;open screen
  44.  beq Pr_bad
  45.  TLwindow #0,#20,#10,#50,#25,#350,#75,#0,#st_7 ;open window 0
  46.  beq Pr_bad
  47.  TLwindow #1,#30,#15,#50,#25,#350,#75,#0,#st_8 ;open window 1
  48.  beq Pr_bad
  49.  TLwindow #2,#40,#20,#50,#25,#350,#75,#0,#st_9 ;open window 2
  50.  beq Pr_bad
  51.  move.w #3,open            ;set number of open windows
  52.  bra.s Pr_cont             ;(window 2 is active)
  53.  
  54. Pr_cycl:
  55.  TLwpoll                   ;wait for a window to be active
  56.  
  57. Pr_cont:
  58.  move.w xxp_Active(a4),d7  ;d7 is active window
  59.  bsr Win0                  ;do this window until it becomes inactive
  60.  tst.w open                ;any windows still open?
  61.  bne Pr_cycl               ;yes, recycle
  62.  rts                       ;exit ok
  63.  
  64. Pr_bad:
  65.  TLbad #2                  ;report if out of mem
  66.  rts
  67.  
  68.  
  69. * window D7 is active
  70. Win0:
  71.  move.b d7,d0             ;put window num in string 1
  72.  add.w #'0',d0
  73.  move.b d0,st_1b
  74.  addq.b #1,st_1a          ;bump A-Z in string 1
  75.  cmp.b #'Z'+1,st_1a
  76.  bne.s W0_draw
  77.  move.b #'A',st_1a
  78.  
  79. W0_draw:
  80.  TLwupdate                ;update window size
  81.  TLstring #1,#10,#20      ;print string 1
  82.  
  83. W0_wait:
  84.  TLkeyboard               ;wait at keyboard
  85.  cmp.b #$96,d0            ;resized?
  86.  beq Win0                 ;redraw if resized
  87.  cmp.b #$93,d0            ;close?
  88.  beq.s W0_close           ;close if close gadget
  89.  cmp.b #$97,d0            ;inactive?
  90.  bne W0_wait              ;keep waiting until inactive
  91.  rts
  92.  
  93. W0_close:
  94.  TLwsub d7                ;close window
  95.  subq.w #1,open           ;dec no. of open windows
  96.  rts
  97.